#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
multiset<LL>s;
set<LL>set1;
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,k;cin>>n>>k;
    set1.clear();s.clear();
    for(LL i=1;i<=n;i++){
        LL x;cin>>x;
        s.insert(x);
        set1.insert(x);
    }
    LL pre=-1;
    for(LL i=0;i<=n+1;i++){
        if(!s.count(i)){
            pre=i;break;
        }
    }
    if(pre==n){
        cout<<(n+k)<<"\n";
    }
    else{
        for(LL i=1;i<=min(k,(LL)1);i++){
            LL num=(pre+(*s.rbegin())+2-1)/2;
            s.insert(num);
        }
        for(auto i:s){
            set1.insert(i);
        }
        cout<<set1.size()<<"\n";
    }
  }
return 0;
}
